#include "NOW.h"
#include "sys/IO.h" // 已经包含<stdio.h>
#include <string.h>
#include <stdlib.h>

// 全局变量定义
int vac[MAX_JOB_N];
PriorityQueue Ready;
PriorityQueue sleep[MAX_RESOURCE_NUM];
int Remain[MAX_RESOURCE_NUM];
const int rsc_num[MAX_RESOURCE_NUM] = {1, 2, 3, 1, 5, 6};
PriorityQueue New;
PriorityQueue waitpid_q;
JobActNode* jobActs[MAX_JOB_N];
Process jobs[MAX_JOB_N];
int Running[CORE_N];
int procN = 0;
_Arrive arrive_q[MAX_JOB_N];
int arrive_n = 0;
const char ins[INSNUM][INSLEN] = {
    "ariv", "exit","fork",
    "kill", "wait","setp",
    "appl", "rels","pflt", 
    "load", "store",

};
Instructions Ins[1];


/*
系统可接受的指令：

[time]+[pid]+[op]+[parameter]
op include:
"ariv" # pid到达，进入New队列/进入磁盘    
"exit" # pid结束，正常退出
"fork" i pid创建子进程，子进程id由系统分配，子进程在i毫秒后结束
"kill" # pid杀死子进程
"wait" # pid等待子进程结束
"setp" i pid设置自己优先级为i
"appl" i pid申请资源i
"rels" i pid释放资源i
"pflt" # pid遇到缺页

*/